#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define rep(i, x, y) for(int i = (x); i <= (y); i++) 
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int , int >;
using vec = vector < int >;
using veg = vector < pii >;
using nu = array < int , 3 >;

int read() {
	int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-', ch = getchar(); 
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar(); return f ? -x : x;
}

const nu mod = { 233223223, 998244353, 1000000009 };
const int N = 5e5 + 10;

int n, m;
string s, x;
nu pw[N], hs[N], hx;

inline int upd(const int &x, const int &mod) { return x + (x >> 31 & mod); }

inline nu get(const int &x) { nu res; rep(i, 0, 2) res[i] = x; return res; }

const nu B = get(10);

inline nu operator + (const nu &a, const nu &b) {
	nu c; rep(i, 0, 2) c[i] = upd(a[i] + b[i] - mod[i], mod[i]); return c;
}

inline nu operator - (const nu &a, const nu &b) {
	nu c; rep(i, 0, 2) c[i] = upd(a[i] - b[i], mod[i]); return c;
}

inline nu operator * (const nu &a, const nu &b) {
	nu c; rep(i, 0, 2) c[i] = 1ll * a[i] * b[i] % mod[i]; return c;
}

inline nu get(const int &l, const int &r) { return hs[r + 1] - hs[l] * pw[r - l + 1]; }

inline vec zfunc(const string &t) {
	int lt = t.size(), l = 0, r = -1;
	vec res; res.resize(lt);
	rep(i, 1, lt - 1) {
		if(i <= r) res[i] = min(r - i + 1, res[i - l]);
		while(res[i] + i < lt && t[res[i] + i] == t[res[i]]) res[i]++;
		if(res[i] + i - 1 > r) r = res[i] + i - 1, l = i;
	} return res;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
	ios :: sync_with_stdio(false); cin.tie(0);
	cin >> s >> x;
	n = s.size(); m = x.size(); 
	pw[0] = get(1); rep(i, 1, n) pw[i] = pw[i - 1] * B;
	hs[0] = get(0); rep(i, 1, n) hs[i] = hs[i - 1] * B + get(s[i - 1] - '0');
	hx = get(0); for(auto c : x) hx = hx * B + get(c - '0');
	if(m > 1) 
		rep(i, 0, n - 1) {
			if(i + m * 2 - 3 >= n) break;
			//			cerr << "check : " << i + 1 << " " << i + m - 1 << endl << i + m << " " << i + m * 2 - 2 << endl;
			if(get(i, i + m - 2) + get(i + m - 1, i + m * 2 - 3) == hx) {
				cout << i + 1 << " " << i + m - 1 << endl << i + m << " " << i + m * 2 - 2 << endl;
				return 0;
			}
		}
	//bool fl = s.size() > 100; int cnt = 0; for(auto c : s) if(cnt < 300) fl &= c == '3', cnt++; else break;
	//if(fl) cout << s.size();
	vec z = zfunc(x + "#" + s);
	//	if(fl) cout << s.size(), exit(0);
	rep(i, 0, n - 1) {
		int lcp = z[i + m + 1]; //cerr << lcp << " " << (x + "#" + s)[i + m + 1] << endl;
		rep(d, m - lcp - 1, m - lcp) {
			if(d < 1) continue;
			//			cerr << "check " << i << " " << i + lcp - 1 << " " << i + lcp << " " << i + lcp + d - 1 << endl;
			if(i + m + d - 1 < n && get(i, i + m - 1) + get(i + m, i + m + d - 1) == hx) {
				cout << i + 1 << " " << i + m << endl << i + m + 1 << " " << i + m + d << endl;
				return 0;
			}
			if(i - d >= 0 && get(i - d, i - 1) + get(i, i + m - 1) == hx) {
				cout << i - d + 1 << " " << i << endl << i + 1 << " " << i + m << endl;
				return 0;
			}
		}
	}
	return 0;
}
